package com.blacktry.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blacktry.entity.model.Course;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.blacktry.entity.model.CourseDistribution;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author blackTry
 * @since 2021-12-05
 */
public interface CourseMapper extends BaseMapper<Course> {
    @Select("SELECT course.course_id,SUBSTRING_INDEX(GROUP_CONCAT(course.course_faculty,','),',',1) as course_faculty,SUBSTRING_INDEX(GROUP_CONCAT(course.course_name,','),',',1) as course_name,SUBSTRING_INDEX(GROUP_CONCAT(course.time_week,','),',',1) as time_week,SUBSTRING_INDEX(GROUP_CONCAT(course.week_num,','),',',1) as week_num,SUBSTRING_INDEX(GROUP_CONCAT(course.logic_time,','),',',1) as logic_time,SUBSTRING_INDEX(GROUP_CONCAT(course.real_time,','),',',1) as real_time,SUBSTRING_INDEX(GROUP_CONCAT(course.time_all,','),',',1) as time_all,SUBSTRING_INDEX(GROUP_CONCAT(course.credit,','),',',1) as credit,SUBSTRING_INDEX(GROUP_CONCAT(course.type,','),',',1) as type,SUBSTRING_INDEX(GROUP_CONCAT(course.nature,','),',',1) as nature,SUBSTRING_INDEX(GROUP_CONCAT(course.examination_way,','),',',1) as examination_way,SUBSTRING_INDEX(GROUP_CONCAT(course.classroom_type,','),',',1) as classroom_type,SUBSTRING_INDEX(GROUP_CONCAT(course.colleges_or_departments,','),',',1) as colleges_or_departments,SUBSTRING_INDEX(GROUP_CONCAT(course.core,','),',',1) as core,SUBSTRING_INDEX(GROUP_CONCAT(course.coach,','),',',1) as coach,SUBSTRING_INDEX(GROUP_CONCAT(course.coach_teacher,','),',',1) as coach_teacher,SUBSTRING_INDEX(GROUP_CONCAT(course.assessment_way,','),',',1) as assessment_way,SUBSTRING_INDEX(GROUP_CONCAT(course.text_book,','),',',1) as text_book,SUBSTRING_INDEX(GROUP_CONCAT(course.reference_book,','),',',1) as reference_book,SUBSTRING_INDEX(GROUP_CONCAT(course.homework_proportion,','),',',1) as homework_proportion,SUBSTRING_INDEX(GROUP_CONCAT(course.test_proportion,','),',',1) as test_proportion,SUBSTRING_INDEX(GROUP_CONCAT(course.lab_proportion,','),',',1) as lab_proportion,SUBSTRING_INDEX(GROUP_CONCAT(course.attendance_proportion,','),',',1) as attendance_proportion,SUBSTRING_INDEX(GROUP_CONCAT(course.performance_proportion,','),',',1) as performance_proportion,SUBSTRING_INDEX(GROUP_CONCAT(course.paper_proportion,','),',',1) as paper_proportion,SUBSTRING_INDEX(GROUP_CONCAT(course.other_proportion,','),',',1) as other_proportion,SUBSTRING_INDEX(GROUP_CONCAT(course.exam_proportion,','),',',1) as exam_proportion,SUBSTRING_INDEX(GROUP_CONCAT(course.time_theory,','),',',1) as time_theory,SUBSTRING_INDEX(GROUP_CONCAT(course.time_practical,','),',',1) as time_practical,SUBSTRING_INDEX(GROUP_CONCAT(course.time_computer,','),',',1) as time_computer,SUBSTRING_INDEX(GROUP_CONCAT(course.time_lab,','),',',1) as time_lab,SUBSTRING_INDEX(GROUP_CONCAT(course.time_practic,','),',',1) as time_practic,SUBSTRING_INDEX(GROUP_CONCAT(course.theory_week,','),',',1) as theory_week,SUBSTRING_INDEX(GROUP_CONCAT(course.remark,','),',',1) as remark,SUM(course.num) as num,GROUP_CONCAT(course.class_num SEPaRaTOR  ',') as class_num FROM course GROUP BY course.course_id ORDER BY course.course_id")
    Page<Course> dataFlush(Course course, Page<Course> coursePage);

    @Delete("Delete from course where 1=1")
    void clear();

    @Select("SELECT COUNT(*) from course")
    int pageMax();

//    Page<Course> selectCourse(String courseId,String courseName);



}
